/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.page.Page;
import com.ybkj.daijia.page.Pageable;
import com.ybkj.daijia.page.impl.PageImpl;
import com.ybkj.daijia.page.impl.PageRequest;
import com.ybkj.daijia.server.mapper.DriverConsumedRecordMapper;
import com.ybkj.daijia.server.model.DriverConsumedRecord;
import com.ybkj.daijia.server.service.DriverConsumedRecordService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Shine
 *
 */
@Service
public class DefaultDriverConsumedRecordService implements
    DriverConsumedRecordService {

    @Autowired
    private DriverConsumedRecordMapper driverConsumedRecordMapper;

    //	/*
//	 * (non-Javadoc)
//	 * @see DriverConsumedRecordService#queryAll(java.lang.Long, java.util.Date, java.util.Date)
//	 */
//	@Override
//	public Page<DriverConsumedRecord> queryAll(Long driverId, Date start,Date end) {
//
//		Pageable pageable = new PageRequest(Pager.getPage(), Pager.getLimit());
//
//		List<DriverConsumedRecord> content = driverConsumedRecordMapper
//				.selectByDriverAndCreated(driverId, start, end,
//						Pager.getOffset(), Pager.getLimit());
//		long total = driverConsumedRecordMapper.countByDriverAndCreated(
//				driverId, start, end);
//
//		return new PageImpl<DriverConsumedRecord>(content, pageable, total);
//	}
//	
//	@Override
//	public List<DriverConsumedRecord> listAll(Long driverId) {
//
//		List<DriverConsumedRecord> content = driverConsumedRecordMapper.selectByDriverAndCreated(driverId, null, null, null, null);
//
//		return content;
//	}
//	
//	/*
//	 * (non-Javadoc)
//	 * @see DriverConsumedRecordService#insertRecord(DriverConsumedRecord)
//	 */
//	@Transactional(rollbackFor = Exception.class)
//	public DriverConsumedRecord insertRecord(
//			DriverConsumedRecord driverConsumedRecord) {
//
//		driverConsumedRecordMapper.insertRecord(driverConsumedRecord);
//
//		return driverConsumedRecord;
//	}
//	/*
//	 * (non-Javadoc)
//	 * @see DriverConsumedRecordService#findOne(java.lang.Long)
//	 */
//	public DriverConsumedRecord findOne(Long id) {
//
//		return driverConsumedRecordMapper.selectByPrimaryKey(id);
//	}
    /*
     * (non-Javadoc)
     * @see DriverConsumedRecordService#findByTypeAndOrderId(java.lang.String, java.lang.Long)
     */
    @Override
    public List<DriverConsumedRecord> findByTypeAndOrderId(String type,
        Long orderId) {

        return driverConsumedRecordMapper.selectByTypeAndOrderId(type, orderId);
    }

    /*
     * (non-Javadoc)
     * @see DriverConsumedRecordService#consumedRecord(java.lang.Long, java.lang.Integer, java.lang.Integer)
     */
    @Override
    public Page<DriverConsumedRecord> consumedRecord(Long driverId,
        Integer page, Integer limit) {

        Pageable pageable = new PageRequest(page, limit);

        List<DriverConsumedRecord> content = driverConsumedRecordMapper
            .selectByDriver(driverId, page * limit, limit);
        long total = driverConsumedRecordMapper.countByDriver(driverId);

        return new PageImpl<DriverConsumedRecord>(content, pageable, total);
    }
//	/*
//	 * (non-Javadoc)
//	 * @see DriverConsumedRecordService#updateByPrimaryKey(DriverConsumedRecord)
//	 */
//	@Override
//	@Transactional(rollbackFor = Exception.class)
//	public int updateByPrimaryKey(DriverConsumedRecord record) {
//
//		return driverConsumedRecordMapper.updateByPrimaryKey(record);
//	}

    @Override
    public List<DriverConsumedRecord> listAll() {
        return driverConsumedRecordMapper.selectAll();
    }


}